-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Build list of the right length in #finalizeSampling #124762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
craigtaverner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Amusingly, the move from functional style, to classic java for loops, did not really increase the number of lines of code.
|
Perhaps we should add the |
|
@iverase out of curiosity, what scenarios lead to a list with unnecessary big capacity? |
|
@idegtiarenko the method #toList initialise the arrays the standard way (new ArrayList()) so you end up with empty slots:
|
Avoid oversize list in internal aggregations.
Avoid oversize list in internal aggregations.

We are using the java command
buckets.stream().map(...).toList()to build internal aggregation with sampling. While this is correct it has a side effect, the final list is normally oversize. In this case we know the length of the final list, therefore let's create list of the right size as we can have thousand of those objects on heap.